import request from '@/utils/request'

// 查询钥匙列表
export function listTenantkey(query) {
  return request({
    url: '/lock/tenantkey/list',
    method: 'get',
    params: query
  })
}

// 查询钥匙详细
export function getTenantkey(id) {
  return request({
    url: '/lock/tenantkey/' + id,
    method: 'get'
  })
}

// 新增钥匙
export function addTenantkey(data) {
  return request({
    url: '/lock/tenantkey',
    method: 'post',
    data: data
  })
}

// 批量新增钥匙
export function batchAddTenantkey(data, params = {}) {
  return request({
    url: '/lock/tenantkey/batch',
    method: 'post',
    data: data,
    params: params
  })
}

// 修改钥匙
export function updateTenantkey(data) {
  return request({
    url: '/lock/tenantkey',
    method: 'put',
    data: data
  })
}
// 修改钥匙
export function updateDate(data) {
  return request({
    url: '/lock/tenantkey/updateDate',
    method: 'put',
    data: data
  })
}
// 修改钥匙
export function updateKey(data) {
  return request({
    url: '/lock/tenantkey/updateKey',
    method: 'put',
    data: data
  })
}

// 删除钥匙
export function delTenantkey(id) {
  return request({
    url: '/lock/tenantkey/' + id,
    method: 'delete'
  })
}

// 冻结密码
export function freezePwd(data) {
  return request({
    url: '/lock/tenantkey/freezePwd',
    method: 'put',
    data: data
  })
}

// 冻结卡片
export function freezeCard(data) {
  return request({
    url: '/lock/tenantkey/freezeCard',
    method: 'put',
    data: data
  })
}

// 清除所有密码
export function clearAllPasswords(mac) {
  return request({
    url: '/lock/tenantkey/delKeyClearPwd',
    method: 'delete',
    params: { mac }
  })
}

// 清除所有卡片
export function delKeyClearCard(mac) {
  return request({
    url: '/lock/tenantkey/delKeyClearCard',
    method: 'delete',
    params: { mac }
  })
}
